package com.example.educationalsystem.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description: 配置MVC图片访问路径//描述
 * @ClassName:MvcConfig//类名
 * @Author:zpc//作者
 * @Date: 2022/10/9 12:35
 */
@Configuration
//@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {
    /**
     * 配置静态资源访问路径
     *   staticPath: "/uploadsImg/**"
     *   uploadsdir
     */

    @Value("${file.staticPath}")
    private String staticPath;
    @Value("${file.uploadsDir}")
    private String uploadsDir;

    @Override
    public void  addResourceHandlers(ResourceHandlerRegistry registry)
    {
        registry.addResourceHandler(staticPath).addResourceLocations("file://"+ uploadsDir);
    }

}
